/**
 * 
 */
package com.taobao.wolfwolf.hibernate.dao.impl;

import java.util.List;

import com.taobao.wolfwolf.hibernate.dao.MaterialDao;
import com.taobao.wolfwolf.hibernate.pojo.Material;

/**
 * @author Tux
 *
 * 创建时间: 2011-5-17 下午03:08:54
 */
@SuppressWarnings("unchecked")
public class MaterialDaoImpl extends BaseDaoImpl implements MaterialDao {

	public Material findById(int id) throws Exception {
		return (Material) getHibernateTemplate().get(Material.class, id);
	}
	
	public List<Material> findByName(String name) throws Exception {
		return super.findByProperty(Material.class, "name", name);
	}

	public List<Material> findAll() throws Exception {
		return getHibernateTemplate().find("from Material");
	}

	public long getTotal() throws Exception {
		return super.countByCriteria(Material.class);
	}

	public List<Material> paging(int page, int limit) throws Exception {
		return super.findByCriteriaByPage(Material.class, page, limit);
	}
}
